ポアソン回帰

data(gala, package = "faraway")
head(gala)
##              Species Endemics  Area Elevation Nearest Scruz Adjacent
## Baltra            58       23 25.09       346     0.6   0.6     1.84
## Bartolome         31       21  1.24       109     0.6  26.3   572.33
## Caldwell           3        3  0.21       114     2.8  58.7     0.78
## Champion          25        9  0.10        46     1.9  47.4     0.18
## Coamano            2        1  0.05        77     1.9   1.9   903.82
## Daphne.Major      18       11  0.34       119     8.0   8.0     1.84

ポアソン回帰

res <- glm(Species ~ ., gala, family = poisson)
summary(res)
## 
## Call:
## glm(formula = Species ~ ., family = poisson, data = gala)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
##  -4.99   -2.93   -0.43    1.32    7.47  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.83e+00   5.96e-02   47.47  < 2e-16 ***
## Endemics     3.39e-02   1.74e-03   19.46  < 2e-16 ***
## Area        -1.07e-04   3.74e-05   -2.85   0.0043 ** 
## Elevation    2.64e-04   1.93e-04    1.36   0.1726    
## Nearest      1.05e-02   1.61e-03    6.50  7.9e-11 ***
## Scruz       -6.83e-04   5.80e-04   -1.18   0.2388    
## Adjacent     4.54e-05   4.80e-05    0.95   0.3444    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 3510.73  on 29  degrees of freedom
## Residual deviance:  313.36  on 23  degrees of freedom
## AIC: 488.2
## 
## Number of Fisher Scoring iterations: 5
## 

超過分散の指標(逸脱度/自由度>1かどうか)

res$deviance/res$df.residual
## [1] 13.62

擬似ポアソン回帰

res.q <- glm(Species ~ ., gala, family = quasipoisson)
summary(res.q)
## 
## Call:
## glm(formula = Species ~ ., family = quasipoisson, data = gala)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
##  -4.99   -2.93   -0.43    1.32    7.47  
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.83e+00   2.15e-01   13.17  3.4e-12 ***
## Endemics     3.39e-02   6.28e-03    5.40  1.8e-05 ***
## Area        -1.07e-04   1.35e-04   -0.79    0.437    
## Elevation    2.64e-04   6.97e-04    0.38    0.709    
## Nearest      1.05e-02   5.81e-03    1.80    0.084 .  
## Scruz       -6.83e-04   2.09e-03   -0.33    0.747    
## Adjacent     4.54e-05   1.73e-04    0.26    0.795    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## (Dispersion parameter for quasipoisson family taken to be 13)
## 
##     Null deviance: 3510.73  on 29  degrees of freedom
## Residual deviance:  313.36  on 23  degrees of freedom
## AIC: NA
## 
## Number of Fisher Scoring iterations: 5
## 

負の二項回帰

library(MASS)
res.nb <- glm.nb(Species ~ ., gala, link = log)
summary(res.nb)
## 
## Call:
## glm.nb(formula = Species ~ ., data = gala, link = log, init.theta = 3.006375104)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -2.119  -0.874  -0.188   0.410   1.720  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  2.51e+00   2.02e-01   12.43  < 2e-16 ***
## Endemics     4.78e-02   9.93e-03    4.81  1.5e-06 ***
## Area        -2.47e-04   2.32e-04   -1.06     0.29    
## Elevation    3.36e-05   9.85e-04    0.03     0.97    
## Nearest      6.12e-03   1.03e-02    0.60     0.55    
## Scruz       -5.16e-04   2.23e-03   -0.23     0.82    
## Adjacent     8.71e-05   2.46e-04    0.35     0.72    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## (Dispersion parameter for Negative Binomial(3.006) family taken to be 1)
## 
##     Null deviance: 152.304  on 29  degrees of freedom
## Residual deviance:  33.396  on 23  degrees of freedom
## AIC: 289.9
## 
## Number of Fisher Scoring iterations: 1
## 
## 
##               Theta:  3.006 
##           Std. Err.:  0.904 
## 
##  2 x log-likelihood:  -273.894